home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gigarom 1
/
Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso
/
FILES
/
BBS
/
HERMES
/
ProtMover6.1.cpt
/
ASCII
/
prefs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-05-29
|
3KB
|
146 lines
#include "Protocol.h"
#include "ASCII.h"
extern ControlHandle GetItemHandle();
extern ProtoRecPtr PRP;
extern ProtoGloPtr PGP;
doSetPrefs()
{
int item;
Str255 text;
DialogPtr dp;
GrafPtr savePort;
GetPort(&savePort);
/* set up the preferences dialog */
dp = GetNewDialog(PRP->procID+0, 0L, -1L);
SetPort(dp);
CenterWindow(dp, 1, 1);
text[0] = 0;
OSTypeToPstrcat(text, &PGP->thePrefs.fType);
SetTextItem(3, text, dp);
SelIText(dp, 3, 0, 32767);
ShowWindow(dp);
OutLineItem(1, dp);
ModalDialog(0L, &item);
GetTextItem(3, text, dp);
PstrToOSType(text, &PGP->thePrefs.fType);
HideWindow(dp);
DisposDialog(dp);
SetPort(savePort);
RWPrefs(TRUE);
}
RWPrefs(write)
int write;
{
register ASCIIPrefPtr app;
register ASCIIPrefHandle aph;
aph = (ASCIIPrefHandle) GetResource('DATA', PRP->procID+0);
if (aph) {
app = *aph;
if (PRP->F.B.transMode == BBSMODE) {
++app;
}
if (write) {
*app = PGP->thePrefs;
ChangedResource(aph);
WriteResource(aph);
}
else {
PGP->thePrefs = *app;
}
}
else {
PGP->thePrefs.fType = 'ttxt';
}
}
OutLineItem(item, dp)
int item;
DialogPtr dp;
{
Rect itemBox;
GetItemRect(item, &itemBox, dp);
PenSize(3, 3);
InsetRect(&itemBox, -4, -4);
FrameRoundRect(&itemBox, 16, 16);
PenNormal();
}
ControlHandle GetItemHandle(item, dp)
register int item;
register DialogPtr dp;
{
int itemType;
Rect itemBox;
ControlHandle itemHandle;
GetDItem(dp, item, &itemType, &itemHandle, &itemBox);
return(itemHandle);
}
SetTextItem(item, text, dp)
int item;
StringPtr text;
DialogPtr dp;
{
register ControlHandle itemHandle;
itemHandle = GetItemHandle(item, dp);
SetIText(itemHandle, text);
}
GetTextItem(item, text, dp)
int item;
StringPtr text;
DialogPtr dp;
{
register ControlHandle itemHandle;
itemHandle = GetItemHandle(item, dp);
GetIText(itemHandle, text);
}
OSTypeToPstrcat(s, ostype)
register StringPtr s;
register OsType *ostype;
{
register int i;
asm {
move.l s, a0
move.b (s)+, i
andi.w #0x00FF, i
adda.w i, s
addq.b #4, (a0)
moveq #3, i
@loop move.b (ostype)+, (s)+
dbf i, @loop
}
}
PstrToOSType(s, ostype)
register StringPtr s;
register OsType *ostype;
{
register int i;
asm {
clr.l (ostype)
move.b (s)+, i
beq.s @the_end
subq.w #1, i
andi.w #0x0003, i
@loop move.b (s)+, (ostype)+
dbf i, @loop
@the_end return
}
}
GetItemRect(item, rect, dp)
int item;
Rect *rect;
DialogPtr dp;
{
int itemType;
ControlHandle itemHandle;
GetDItem(dp, item, &itemType, &itemHandle, rect);
}